home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2002 September / PCpro_2002_09.ISO / techtalk / automationsuite / 247setup.exe / {app} / Template / sql_backup.ini < prev    next >
Encoding:
INI File  |  2002-07-11  |  2.8 KB  |  89 lines

  1. ; Note: comment lines in .INI files always start with a semicolon
  2.  
  3. [Template]
  4. Description=Use this template to create a job automating the task of backup of the SQL Server databases by taking a dump of all the existing databases.
  5.  
  6.  
  7. [Variables]
  8. ; Key values that have their name enclosed in % signs will be used for 
  9. ; template wizard questionnaire and substitution variables
  10. ; such key values should consist of 2 comma separated parts:
  11. ;    1. Field Edit Style (EDIT, YES/NO, FILE BROWSE, 
  12. ;                         DIR BROWSE, PROCESS BROWSE,
  13. ;                         FTP BROWSE, MAIL PROFILE LIST,
  14. ;                         REMOTE FILE BROWSE, REMOTE DIR BROWSE,
  15. ;                         REMOTE AGENT LIST, DB PROFILE LIST)
  16. ;    2. Prompt
  17. ;
  18. ; Example: %VAR%=EDIT,What is the name of the service that you want to monitor?
  19. ;
  20. ; Key values that don't have their name enclosed in % signs will be used for 
  21. ; job properties (See online help on "Job property names for use with JDL commands" 
  22. ; topic for more details).
  23. ;
  24. ; Example: DAY_NUMBER=1
  25.  
  26. %DB_PROFILE%=DB PROFILE LIST,Which SQL Server do you want to backup?
  27. %EMAIL_RECIPIENT%=EDIT,To whom do you want to sent the email alert in case if the backup fails:
  28. %EMAIL_PROFILE%=MAIL PROFILE LIST,If you use MAPI email interface, then which email profile do you want to use? If you use Lotus Notes or SMTP email interfaces, enter User ID required for logging to your email system.
  29. %EMAIL_PASSWORD%=EDIT,If you are required to login to your email system, what is your password:
  30. JOB_TYPE=D
  31. PROFILE=%DB_PROFILE%
  32. SCHEDULE_TYPE=D
  33. LOG=Y
  34. ASYNC=Y
  35. MONDAY=Y
  36. TUESDAY=Y
  37. WEDNESDAY=Y
  38. THURSDAY=Y
  39. WEDNESDAY=Y
  40. FRIDAY=Y
  41. SKIP_HOLIDAY=Y
  42. START_TIME=23:00
  43. SKIP=N
  44. MSG_ERROR=Y
  45. MSG_EMAIL=Y
  46. MSG_ACCOUNT=%EMAIL_PROFILE%
  47. MSG_PASSWORD=%EMAIL_PASSWORD%
  48. MSG_RECIPIENT=%EMAIL_RECIPIENT%
  49. DESCRIPTION=Every night this job backups the specified SQL Server.
  50.  
  51. ; Notes: The script bellow can include substitution variables.
  52. ;        Substitution variables must be specified in %VAR% format 
  53. ;        where VAR is the variable name.
  54. ;
  55. ; Everything after the next line will be used for the template script.
  56. ;========================================================================================
  57. [Body]
  58.  
  59. DECLARE @dbname VARCHAR(50)
  60. DECLARE @dblast VARCHAR (50)
  61.  
  62. SET nocount ON
  63.  
  64. SELECT @dblast = MAX(name)
  65. FROM sysdatabases
  66. WHERE name NOT IN ('tempdb','pubs')
  67.  
  68. DECLARE db scroll CURSOR FOR
  69. SELECT name
  70. FROM sysdatabases
  71. WHERE name NOT IN ('tempdb','pubs')
  72. ORDER BY name
  73.  
  74. OPEN db
  75.  
  76. FETCH NEXT FROM db INTO @dbname
  77.  
  78. WHILE (@@fetch_status = 0)
  79. BEGIN
  80.       IF (@dbname <> @dblast)
  81.         DUMP DATABASE @dbname TO '%DEVICE%' WITH  nounload, noinit, skip, stats
  82.     ELSE
  83.         DUMP DATABASE @dbname TO '%DEVICE%' WITH  unload, noinit, skip, stats
  84.  
  85.    FETCH NEXT FROM db INTO @dbname
  86. END
  87.  
  88. DEALLOCATE db
  89.